<template>
  <div class="animate-css-demo">
    <h2>Animate.css 集成示例</h2>

    <div class="animation-selector">
      <label>选择动画效果：</label>
      <select v-model="selectedAnimation">
        <option value="bounce">弹跳</option>
        <option value="fadeInDown">从上淡入</option>
        <option value="fadeInUp">从下淡入</option>
        <option value="fadeInLeft">从左淡入</option>
        <option value="fadeInRight">从右淡入</option>
        <option value="rotateIn">旋转进入</option>
        <option value="zoomIn">缩放进入</option>
        <option value="slideInDown">从上滑入</option>
        <option value="rollIn">滚动进入</option>
      </select>
    </div>

    <button @click="show = !show" class="trigger-btn">
      {{ show ? '隐藏' : '显示' }}
    </button>

    <Transition
      :enter-active-class="`animate__animated animate__${selectedAnimation}`"
      :leave-active-class="'animate__animated animate__fadeOut'"
    >
      <div v-if="show" class="animate-box">
        <h3>{{ getAnimationName() }}</h3>
        <p>使用 Animate.css 库的动画效果</p>
      </div>
    </Transition>
  </div>
</template>
<script setup>
import { ref } from 'vue'

const show = ref(false)
const selectedAnimation = ref('bounce')

const getAnimationName = () => {
  const names = {
    bounce: '弹跳动画',
    fadeInDown: '从上淡入',
    fadeInUp: '从下淡入',
    fadeInLeft: '从左淡入',
    fadeInRight: '从右淡入',
    rotateIn: '旋转进入',
    zoomIn: '缩放进入',
    slideInDown: '从上滑入',
    rollIn: '滚动进入',
  }
  return names[selectedAnimation.value]
}
</script>
<style>
/* 引入 Animate.css */
@import 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css';
</style>
<style scoped>
.animate-css-demo {
  padding: 20px;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.animation-selector {
  margin: 20px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.animation-selector label {
  font-weight: bold;
  color: #2c3e50;
}

.animation-selector select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.trigger-btn {
  padding: 12px 24px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  margin: 20px;
}

.trigger-btn:hover {
  background: #c0392b;
}

.animate-box {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  border-radius: 10px;
  margin: 20px auto;
  max-width: 400px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.animate-box h3 {
  margin: 0 0 10px 0;
}

.animate-box p {
  margin: 0;
  opacity: 0.9;
}
</style>
